import { Tend } from '@/domain/dataBoard/types/tend';
import { Overview } from './common';

/**
 * 分页信息
 */
export type Page = {
  page: number;
  pageSize?: number;
  total?: number;
};

export type PageRowStatus = {
  /** 1正常 2 禁用*/
  status: number; //1正常 2 禁用
  create_time: string;
  update_time: string;
};
/**
 * 列信息
 */
export type Column = {
  prop: string;
  label: string;
  sortable: boolean;
};

/**
 * 选择状态
 */
export type Options = {
  label?: number;
  value?: number;
  en_value?: number;
  group?: string;
  businessline?: string;
  businessline_id?: number;
  children?: Object;
};

/**
 * select键值对类型
 */
export type selectParam = Record<string, Array<string | number> | string | number>;
/**
 * 页面查询项字段项
 */
export type PageItemSearch = {
  type?: string;
  column: string;
  label?: boolean;
  placeholder?: string;
  value?: string;
  disable?: boolean;
  options?: Array<Options>;
};
export type ResSearch = Array<PageItemSearch>;

/**
 * 列表事件弹窗动作
 */
export enum OpType {
  add = 'add',
  edit = 'edit',
  show = 'show'
}
/**
 * 行编辑内动作枚举
 */
export enum OpButtonKey {
  /**新增 */
  memberAdd = 'add',
  /**修改*/
  memberEdit = 'edit',
  /**展示*/
  memberShow = 'show',
  /**冻结*/
  memberStatusOff = 'statusOff',
  /**解冻*/
  memberStatusOn = 'statusOn'
}
/**操作按钮 */
export type OpButton = {
  key: OpButtonKey;
  value: string;
};

/**
 * 返回数据格式
 */
export type ResPageList<T> = {
  column?: Array<Column>;
  overview?: Overview;
  datas: Array<{ row: T; op_group: Array<OpButton> }>;
  page: Page;
  trend?: Tend;
};

/**
 * 页面列表内动作回调
 */
export type OpGroupCallBack<T, U> = (key: U, node: Partial<T>) => void | Promise<void>;
/**
 * 页面按钮状态
 */
export type ChangePageState = (type: OpType, status: boolean) => void;
/**
 * 选择行
 */
export type SelectRow<P, T> = Partial<{ selectKey: Array<P>; selectRow: Array<T> }>;
